import formJs from "./regexDetail.js"; //新增弹框配置项
import TableData from "@/components/stationProductionPage/waterManage/public/el-tables"; //主页面列表
import TableLyout from '@/components/commonPublic/tableLyout.vue'
import PaginationS from "@/components/stationProductionPage/TensionManage/TensionRealTime/el-pagination"; //弹框分页
import pressureCharts from "@/components/stationProductionPage/TensionManage/TensionRealTime/pressureCharts"; //油压
import tensioningCharts from "@/components/stationProductionPage/TensionManage/TensionRealTime/tensioningCharts"; //张拉力
import elongationCharts from "@/components/stationProductionPage/TensionManage/TensionRealTime/elongationCharts"; //伸长量
import tripCharts from "@/components/stationProductionPage/TensionManage/TensionRealTime/tripCharts"; //伸长量
import {
    getTensioningProcessDetailLists, //2级详情接口
} from "@/api/request.js";

export default {
    props: [
        "dialogVisible", "currentRow", "getList"
    ],
    data() {
        return {
            visible: "",
            queryCriteriaData: {}, //分页
            searchObj: formJs.searchObj, //搜索条件
            table_config: formJs.table_config, //列表
            currentDetail: null,
            material_config: formJs.material_config, //材料配置项
            level: [],
            earlyWarning: [], //预警标准
            chartsLoading: false,
            typeData: [{
                    text: "张拉力",
                    show: true
                },
                {
                    text: "油压",
                    show: false
                },
                {
                    text: "伸长量",
                    show: false
                },
                {
                    text: "顶行程",
                    show: false
                },
            ],
            tensioningData: [], //张拉力--图表数据
            pressureData: [], //油压--图表数据
            elongationData: [], //伸长量--图表数据
            tripData: [], //顶行程--图表数据

            materialGetList: {
                fCompanyid: "",
                namberId: "", // 孔号id
                page: 1, // 当前页码
                pageSize: 10, // 每页显示条数
            }, //调取过程数据详情接口传参
            navigatepageNums_M: null, //过程数据-详情-是否显示分页
            queryCriteriaDatas_M: {}, //过程数据-详情-分页


            loading: false,


            title: null,
            isLock: false,
            dialogHeight: null,

            btnShow: true,
            WbsRow: null,

        };
    },
    components: {
        // publicForm,
        TableLyout,
        TableData,
        PaginationS,
        pressureCharts, //油石比图表
        tensioningCharts, //温度曲线
        elongationCharts, //伸长量
        tripCharts, //顶行程
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    this.materialGetList.fCompanyid = this.currentDetail.fCompanyid;
                    this.materialGetList.namberId = this.currentDetail.fNamberid; // 孔号id

                    this.getDetail(this.materialGetList)


                }
            },

            immediate: true,
        },
        // getDetail
    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.btnShow = true

        this.getHeight();
    },
    methods: {
        // 点击图表切换
        changeType(e, index) {
            for (let i in this.typeData) {
                if (parseFloat(i) === index) {
                    this.typeData[i].show = true;
                } else {
                    this.typeData[i].show = false;
                }
            }
            this.typeDataNum = index;
        },

        clickLegend() {},
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        closeDialog1() {
            this.$emit("close1");
        },

        rowChange1(val) {
            this.getList.fId = val.fVarietyid;
            this.types = val
            this.yj_searchForm(this.getList)
        },
        // 点击材料
        rowChange(val) {
            this.WbsRow = val
            // this.dataFid = val.fId;
        },
        // WBS

        getDetail(data) {
            this.visible = true;
            this.loading = true;
            this.fPhotofilelist = [];
            this.materialData = [];
            this.tensioningData = [];
            this.pressureData = [];
            this.elongationData = [];
            this.tripData = [];
            getTensioningProcessDetailLists(data)
                .then((res) => {
                    if (res.errcode == 0) {
                        var that = this;
                        that.loading = false;
                        // that.dialogEditVisibleCon = true;
                        that.materialData = res.data.pageInfo.list;
                        that.queryCriteriaDatas_M = res.data.pageInfo; //分页信息
                        that.navigatepageNums_M =
                            that.queryCriteriaDatas_M.navigatepageNums.length;
                        that.tensioningData = [
                            res.data.line.recorddatesList,
                            res.data.line.force1List,
                            res.data.line.force2List,
                        ]; //张拉力--图表数据
                        that.pressureData = [
                            res.data.line.recorddatesList,
                            res.data.line.pressure1List,
                            res.data.line.pressure2List,
                        ]; //油压--图表数据
                        that.elongationData = [
                            res.data.line.recorddatesList,
                            res.data.line.elongation1List,
                            res.data.line.elongation2List,
                        ]; //伸长量--图表数据
                        that.tripData = [
                            res.data.line.recorddatesList,
                            res.data.line.topstroke1List,
                            res.data.line.topstroke2List,
                        ]; //顶行程--图表数据
                    } else {
                        this.$message.error(res.msg);
                        this.loading = false;
                    }
                })
                .catch((error) => {
                    this.$message.error(error.msg);
                    this.loading = false;
                });
        },



    },
};